977C - Less or Equal - CodeForces Solution


sortings *1200

Please click on ads to support us..

Python Code:

l,k = map(int,input().split())
arr = sorted(list(map(int,input().split())))
if k == 0:
    ans = arr[0]-1
else:
    ans = arr[k-1]
cnt = 0
for i in arr:
    if i <=ans:
        cnt+=1
print(-1 if ans<1 or cnt!=k else ans)


Comments

Submit
0 Comments
More Questions

755C - PolandBall and Forest
456B - Fedya and Maths
376B - IOU
1623B - Game on Ranges
1118A - Water Buying
1462C - Unique Number
301A - Yaroslav and Sequence
38A - Army
38C - Blinds
1197A - DIY Wooden Ladder
1717D - Madoka and The Corruption Scheme
1296D - Fight with Monsters
729D - Sea Battle
788A - Functions again
1245B - Restricted RPS
1490D - Permutation Transformation
1087B - Div Times Mod
1213B - Bad Prices
1726B - Mainak and Interesting Sequence
1726D - Edge Split
1726C - Jatayu's Balanced Bracket Sequence
1726A - Mainak and Array
1613C - Poisoned Dagger
475B - Strongly Connected City
652B - z-sort
124B - Permutations
1496C - Diamond Miner
680B - Bear and Finding Criminals
1036E - Covered Points
1015D - Walking Between Houses